package com.mlk.activity.service.impl;

import com.mlk.activity.mapper.EngActivityMapper;
import com.mlk.activity.po.EngActivity;
import com.mlk.activity.service.EngActivityService;
import com.mlk.core.component.page.Pager;
import com.mlk.core.util.ServerResponse;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class EngActivityServiceImpl implements EngActivityService {

    @Resource
    private EngActivityMapper engActivityMapper;
    @Override
    public Pager listPage() {
        return Pager.adapt(this.engActivityMapper.selectList(null));
    }

    @Override
    public ServerResponse listActivity(EngActivity engActivity) {
        return ServerResponse.ok(this.engActivityMapper.listActivity(engActivity));
    }

    @Override
    public ServerResponse updateActivity(Integer id, String name, String content) {
        int count = this.engActivityMapper.updateById(EngActivity.builder().id(id).name(name).content(content).build());
        if(count == 0 ){
            return ServerResponse.fail("修改失败！");
        }
        return ServerResponse.ok("修改成功");
    }
}
